<template>
  <div class="market-page">
    <div class="all-market">
      <van-list
        ref="list"
        v-model="loading"
        :finished="finished"
        :finished-text="'没有更多了'"
        :offset="500"
        @load="getCustomerBuildingAnalysisList"
      >
        <custom-detail-house-list
          :itemInfo='v'
          v-for='(v,k) in analysisListData'
          :key='k'
        ></custom-detail-house-list>
      </van-list>
    </div>
  </div>
</template>
<script>
import CustomDetailHouseList from 'COMP/Custom/CustomDetailHouseList'
import CustomService from 'SERVICE/customService'
export default {
  data: () => ({
    clientId: '',
    size: 10,
    current: 1,
    haveData: true,
    hotResult: [],
    titleBarConf: {
      title: '热门楼盘'
    },
    selectedCity: '',
    broker: 705,
    marketList: [],
    loading: false,
    finished: false,
    locationIcon: require('IMG/market/juxing.png'),
    agentIdInfo: null,
    resInfo: null,
    borderBottom: true,
    containerHeight: '0',
    vipInfo: {},
    historyCity: '',
    scrollTop: 0,
    analysisListData: []
  }),
  created () {
    this.clientId = this.$route.query.clientId
  },
  methods: {
    /**
     * 客户详情-楼盘分析分页列表
     */
    async getCustomerBuildingAnalysisList () {
      try {
        let id = this.clientId
        let current = this.current
        let size = this.size
        const result = await CustomService.getCustomerBuildingAnalysisList(id, current, size)
        if (this.current > 1) {
          this.analysisListData = this.analysisListData.concat(result.records)
        } else {
          this.analysisListData = result.records
        }
        for (var i in this.analysisListData) {
          var item = this.analysisListData[i]
          item.progress = Number(item.intentionality)
          let color
          if (item.progress >= Number(70)) {
            color = '#007AE6'
          } else {
            color = '#cccccc'
          }
          item.color = color
          item.textColor = color
          if (item.saleStatus == 0) {
            item.saleStr = '在售'
          } else if (item.saleStatus == 1) {
            item.saleStr = '待售'
          } else {
            item.saleStr = '售罄'
          }
          if (item.shelfFlag == 0) {
            item.shelfStr = '上架'
          } else {
            item.shelfStr = '下架'
          }
          let tags = []
          let tag
          if (item.shelfFlag == 0) {
            tag = item.saleStr
          } else {
            tag = '下架'
          }
          if (item.projectTagArr && item.projectTagArr.length > 0) {
            item.projectTagArr.unshift(tag)
            tags = item.projectTagArr
            if (tags.length > 3) {
              tags.pop()
            }
          } else {
            tags.push(tag)
          }
          item.linkerTags = tags
        }
        if (result.pages <= this.current) {
          this.finished = true
        } else {
          this.current++
        }
        this.loading = false
      } catch (error) {
        console.log(console.error)
      }
    }
  },
  components: {
    CustomDetailHouseList
  }
}
</script>
<style lang="less" scoped>
.market-page {
  padding: 0 16px;
  .fixed {
    position: fixed;
    width: 100%;
    background: #ffffff;
    z-index: 3;
  }
  .already-open-page {
    margin-top: 105px;
  }
  .search-box {
    position: relative;
    width: 375px;
    height: 44px;
    padding: 7px 0;
    > .search-comp {
      height: 30px;
      margin: 0px 16px;
      box-sizing: border-box;
    }
    > .location-icon {
      position: absolute;
      width: 24px;
      height: 24px;
      transform: translate(-50%, -50%);
      right: 8px;
      top: 15px;
    }
  }
  .hot-recommend {
    margin-top: 30px;
  }
}
</style>
